<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"></c:set>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>用户管理</title>
<script src="${ctx}/static/jquery/jquery-2.1.1.min.js" type="text/javascript"></script>
<script src="${ctx}/static/jquery/jquery-migrate-1.1.1.min.js" type="text/javascript"></script>

<link href="${ctx}/static/bootstrap/3.3.4/css_default/bootstrap.min.css" type="text/css" rel="stylesheet" />
<script src="${ctx}/static/bootstrap/3.3.4/js/bootstrap.min.js" type="text/javascript"></script>
<link href="${ctx}/static/awesome/4.4/css/font-awesome.min.css" rel="stylesheet" />

<!--datatable-->
<link rel="stylesheet" href="${ctx}/static/dataTables/css/jquery.dataTables.min.css" />
<script type="text/javascript" src="${ctx}/static/dataTables/jquery.dataTables.js"></script>

<!--datePicker.js-->
<script type="text/javascript" src="${ctx}/static/My97DatePicker/WdatePicker.js"></script>

<!--juicer-->
<script type="text/javascript" src="${ctx}/static/juicer/juicer-min.js"></script>

<!-- jquery-md5.js -->
<script type="text/javascript" src='${ctx}/common/js/JQuery.md5.js'></script>

<!-- bootstrapvalidator -->
<link href="${ctx}/static/dist/css/bootstrapValidator.min.css" rel="stylesheet" />
<script type="text/javascript" src="${ctx}/static/dist/js/bootstrapValidator.min.js"></script>

<script type="text/javascript" src="user.js"></script>

<link rel="stylesheet" href="${ctx}/common/css/style.css" />
</head>
<body>


	<div class="container-fluid">



		<div class='row' style='padding: 30px 0 20px 15px;'>
			<div style='float:left;margin-right:10px;'>
				<label id='lblSelect'>
					<span>机构类型</span>
					<select id="selectPointOfInterest" class="orginizationSelect">
						<option value='0'>总公司</option>
						<option value='1'>出租车公司</option>
						<option value='2'>专车公司</option>
					</select>
				</label>
			</div>
			<div style='float:left;margin-right:10px;'>
				<label id='lblSelect'>
					<span>公司名称</span>
					<select id="selectPointOfInterest" class='companySelect' style='width:250px;'>
						
					</select>
					<script type="text/template" id="companySelectTpl">
							-~each list as item+
							<option value="#-item.organizationId+">#-item.organizationName+</option>
							-~/each+
						  	</script>

				</label>
			</div>
			<div class='col-md-2'>
				<shiro:hasPermission name='sys:user:view'>
				<button class="btn btn-search btn-info" style="padding: 0 10px;"><i class='fa fa-search'></i>查询</button>
				</shiro:hasPermission>
				<shiro:hasPermission name='sys:user:add'>
				<button class="btn btn-add btn-success" style="padding: 0 10px;"><i class='fa fa-plus'></i>添加</button>
				</shiro:hasPermission>
				<button onclick="window.location.reload()" class='btn btn-primary' style="padding:0 10px;"><i class='glyphicon glyphicon-repeat'></i>刷新</button>
				
			</div>
		</div>

		<!--表格-->
		<div class="row">
			<div class="col-md-12">
				<table id="table" class="table table-bordered">
					<thead>
						<tr>
							<th>登录名</th>
							<th>姓名</th>
							<th>电话</th>
							<th>机构名称</th>
							<th>城市名称</th>
							<th>创建时间</th>
							<th>状态</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>

					</tbody>
				</table>
			</div>
		</div>


		<!--添加用户模态框-->
		<div class="modal fade addusermodal" id="myModalAdd" tabindex="-1" role="dialog"
			aria-labelledby="myLargeModalLabel" aria-hidden="true">
			<div class="modal-dialog modal-lg">
				<div class="modal-content modal-addUser">
					<div class="modal-header addUserHeader">
						<button type="button" class="close" data-dismiss="modal">
							<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
						</button>
						<h4 class="modal-title" id="myModalLabel">添加用户</h4>
					</div>
					<form id="adduserform" class="form-horizontal">
					<div class="modal-body addUserCss">
							<div class="row">
								<div class='col-md-6 form-group' style='vertical-align: bottom;'>
								    <label class="col-md-4 control-label">公司类型:</label>
								    <div class="col-md-8">
								    	<label id='lblSelect' class='roleLabel'>
									        <select id="selectPointOfInterest" class='addorginizationSelect' style='height:30px;'>
												<option value="1">出租车</option>
												<option value="2">专车</option>
												<option value='0'>总公司</option>
											</select>
										</label>
								    </div>
								</div>
								<div class='col-md-6 form-group'>
								    <label class="col-md-4 control-label">公司名称:</label>
								    <div class="col-md-8">
								    <label id='lblSelect' class='roleLabel'>
								      <select id="selectPointOfInterest" class='addcompanySelect' style='height:30px;'>
							
										</select>
										<script type="text/template" id="addcompanySelectTpl">
										-~each list as item+
										<option value="#-item.organizationId+">#-item.organizationName+</option>
										-~/each+
						  			</script>
							  		</label>
								    </div>
								</div>
							</div>
							<div class='row' style='margin-bottom:7px;'>
							<div class='col-md-6 form-group'>
							    <label class="col-md-4 control-label">密码:</label>
							    <div class="col-md-8">
							      <input type="text" class="form-control addpassword" name="addpassword" maxlength='20'>
							    </div>
							</div>
							<div class='col-md-6 form-group'>
								<label class="col-md-4 control-label">电话:</label>
							    <div class="col-md-8">
							      <input type="text" class="form-control addtelphone" name="addtelphone" maxlength='11'>
							    </div>
							</div>
						</div>
						<div class='row' style='margin-bottom:7px;'>
							<div class='col-md-6 form-group'>
							    <label class="col-md-4 control-label">真实姓名:</label>
							    <div class="col-md-8">
							      <input type="text" class="form-control addtrueName" name="addtrueName" maxlength='6'>
							    </div>
							</div>
							<div class='col-md-6 form-group'>
								<label class="col-md-4 control-label">备注:</label>
							    <div class="col-md-8">
							      <input type="text" class="form-control addbeizhu" maxlength='15'>
							    </div>
							</div>
						</div>
						<div class='row'>
							<div class='col-md-6 form-group'>
							    <label class="col-md-4 control-label" style='padding-top:5px;'>登录状态:</label>
							    <div class="col-md-8 addStatus">
							      <label style='margin-right:10px'><input value='1' type='radio' name='loginornot' checked>是</label>
							      <label><input value='0' type='radio' name='loginornot'>否</label>
							    </div>
							</div>
							<div class='col-md-6 form-group'>
								<label class="col-md-4 control-label" style='padding-top:5px;'>角色:</label>
							    <div class="col-md-8">
							    <label id='lblSelect' class='roleLabel'>
							      <select id="selectPointOfInterest" class='addroleSelect' style='height:30px;'>
						
									</select>
									<script type="text/template" id="addroleSelectTpl">
										-~each list as item+
										<option value="#-item.sysRoleId+">#-item.roleName+</option>
										-~/each+
									
						  			</script>
						  		</label>
							    </div>
							</div>
						</div>
						<div class='row'>
							<div class='col-md-6 form-group'>
								<label class="col-md-4 control-label">登录名:</label>
							    <div class="col-md-8">
							      <input type="text" class="form-control addloginname" name="addloginname" maxlength='10'>
							    </div>
							</div>
						</div>
							
						</div>
						
						<div class="modal-footer addUserFooter">
							<button type="submit" class="btn btn-default add-confirm-btn">确认</button>
							<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
						</div>
					</div>
					</form>
					
				</div>
			</div>
		</div>


		<!--编辑用户模态框-->
		<div class="modal fade editusermodal" id="myModalEdit" tabindex="-1" role="dialog"
			aria-labelledby="myLargeModalLabel" aria-hidden="true">
			<div class="modal-dialog modal-lg">
				<div class="modal-content compileUserCss">
					<div class="modal-header editUserHeader">
						<button type="button" class="close" data-dismiss="modal">
							<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
						</button>
						<h4 class="modal-title" id="myModalLabel">编辑用户</h4>
					</div>
					<form id="edituserform" class="form-horizontal">
					<div class="modal-body">
						<div class='row'>
							<div class='col-md-6 form-group'>
							    <label class="col-md-4 control-label">登录名</label>
							    <div class="col-md-8 editloginName">
							    	<input type='text' class="form-control" name="editloginName" maxlength='10'/>
							    </div>
							</div>
							<div class='col-md-6 form-group'>
								<label class="col-md-4 control-label">真实姓名</label>
							    <div class="col-md-8 edittrueName">
							    	<input type='text' class="form-control" name="edittrueName" maxlength='6'/>
							    </div>
							</div>
						</div>
						<div class='row'>
							<div class='col-md-6 form-group'>
								<label class="col-md-4 control-label">电话</label>
							    <div class="col-md-8">
							      <input type="text" class="form-control edittelphone" name="edittelphone" maxlength='11'>
							    </div>
							</div>
							<div class='col-md-6 form-group'>
							    <label class="col-md-4 control-label">公司类型</label>
							    <div class="col-md-8">
							    <label id='lblSelect' class='roleLabel'>
							        <select id="selectPointOfInterest" class='editorginizationSelect' style='height:30px;'>
										<option value="1">出租车</option>
										<option value="2">专车</option>
										<option value="0">总公司</option>
									</select>
								</label>	
							    </div>
							</div>
						</div>
						<div class='row'>
							<div class='col-md-6 form-group'>
								<label class="col-md-4 control-label">备注</label>
							    <div class="col-md-8">
							      <input type="text" class="form-control editbeizhu" maxlength='20'>
							    </div>
							</div>
							<div class='col-md-6 form-group'>
								<label class="col-md-4 control-label">角色名称</label>
							    <div class="col-md-8 editroleName">
							    <label id='lblSelect' class='roleLabel'>
							    	<select id="selectPointOfInterest" class='editroleSelect'  style='height:30px;'>
						
									</select>
									<script type="text/template" id="editroleSelectTpl">
										-~each list as item+
										<option value="#-item.sysRoleId+">#-item.roleName+</option>
										-~/each+
						  			</script>
						  		</label>
							    </div>
							</div>
						</div>
						<div class='row'>
							
							<div class='col-md-6 form-group'>
							    <label class="col-md-4 control-label">公司名称</label>
							    <div class="col-md-8">
							    <label id='lblSelect' class='roleLabel'>
							      <select id="selectPointOfInterest" class='editcompanySelect' style='height:30px;'>
						
									</select>
									<script type="text/template" id="editcompanySelectTpl">
										-~each list as item+
										<option value="#-item.organizationId+">#-item.organizationName+</option>
										-~/each+
						  			</script>
						  		</label>
							    </div>
							</div>
							<div class='col-md-6 form-group'>
								<label class="col-md-4 control-label">登录状态</label>
							    <div class="col-md-8 edituserStatus">
							    	<label style='margin-right:10px'><input value='1' type='radio' name='editloginornot'>是</label>
							        <label><input value='0' type='radio' name='editloginornot'>否</label>
							    </div>
							</div>
						</div>
						<div class='row'>
							
						</div>
					</div>
					<div class="modal-footer editUserFooter">
						<button class="btn btn-default save-edit-btn">保存修改</button>
						<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
					</div>
					</form>
				</div>
			</div>
		</div>

		<!--查看用户详情模态框-->
		<div class="modal fade" id="myModalDetail" tabindex="-1" role="dialog"
			aria-labelledby="myLargeModalLabel" aria-hidden="true">
			<div class="modal-dialog modal-lg">
				<div class="modal-content userInformationCss">
					<div class="modal-header userInformationCssHeader">
						<button type="button" class="close" data-dismiss="modal">
							<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
						</button>
						<h4 class="modal-title" id="myModalLabel">用户详情</h4>
					</div>
					<div class="modal-body">
						<div class='row'>
							<div class='col-md-6 form-group'>
							    <label class="col-sm-4 control-label">登录名:</label>
							    <div class="col-sm-8 loginName">
							    </div>
							</div>
							<div class='col-md-6'>
								<label class="col-sm-4 control-label">姓名:</label>
							    <div class="col-sm-8 trueName">
							    </div>
							</div>
						</div>
						<div class='row'>
							<div class='col-md-6 form-group'>
							    <label class="col-sm-4 control-label">角色名称:</label>
							    <div class="col-sm-8 roleName">
							    </div>
							</div>
							<div class='col-md-6'>
								<label class="col-sm-4 control-label">机构名称:</label>
							    <div class="col-sm-8 organizationName">
							    </div>
							</div>
						</div>
						<div class='row'>
							<div class='col-md-6 form-group'>
							    <label class="col-sm-4 control-label">创建时间:</label>
							    <div class="col-sm-8 createTime">
							    </div>
							</div>
							<div class='col-md-6 form-group'>
							    <label class="col-sm-4 control-label">更新时间:</label>
							    <div class="col-sm-8 updateTime">
							      
							    </div>
							</div>
							<!-- <div class='col-md-6'>
								<label class="col-sm-4 control-label">创建者</label>
							    <div class="col-sm-8 createUserId">
							    </div>
							</div> -->
						</div>
						<div class='row'>
							<div class='col-md-6 form-group'>
							    <label class="col-sm-4 control-label">城市名称:</label>
							    <div class="col-sm-8 cityName">
							    </div>
							</div>
							<div class='col-md-6'>
								<label class="col-sm-4 control-label">是否可登录:</label>
							    <div class="col-sm-8 userStatus">
							    </div>
							</div>
							<!-- <div class='col-md-6 '>
								<label class="col-sm-4 control-label">更新者</label>
							    <div class="col-sm-8 updateUserId">
							    </div>
							</div> -->
						</div>
					</div>
					<div class="modal-footer userInformationCssFooter">
						<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
					</div>
				</div>
			</div>
		</div>

		<!--修改密码模态框-->
		<div class="modal fade" id="myModaleditpass" tabindex="-1" role="dialog"
			aria-labelledby="myLargeModalLabel" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content amendPasswordCss">
					<div class="modal-header modal-amendPasswordHeader">
						<button type="button" class="close" data-dismiss="modal">
							<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
						</button>
						<h4 class="modal-title" id="myModalLabel">修改密码:</h4>
					</div>
					<form id="edituserpswform" class="form-horizontal">
					<div class="modal-body">
						<!-- <div class='row'>
							<div class='col-md-12 form-group'>
							    <label class="col-sm-4 control-label">旧密码</label>
							    <div class="col-sm-8">
							    	<input type='password' class='oldpassword form-control' placeholder='请输入旧密码' />
							    </div>
							</div>
						</div> -->
						<div class='row' >
							<div class='col-md-12 form-group'>
							    <label class="col-sm-3 control-label">新密码</label>
							    <div class="col-sm-9">
							    	<input type='password' class='newpassword form-control' name="newpassword" placeholder='请输入新密码' maxlength='20' />
							    </div>
							</div>
						</div>
						<div class='row' style="margin-top:10px;">
							<div class='col-md-12 form-group'>
							    <label class="col-sm-3 control-label">确认密码</label>
							    <div class="col-sm-9">
							    	<input type='password' class='newpasswordagain form-control' name="newpasswordagain" placeholder='请再次确认新密码' maxlength='20' />
							    </div>
							</div>
						</div>
						
					</div>
					<div class="modal-footer modal-amendPasswordFooter">
						<button class="btn btn-default btn-confirm-edit-password">确认修改</button>
						<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
					</div>
					</form>
				</div>
			</div>
		</div>

	</div>




</body>
</html>
<script type='text/javascript'>
	function userTable(companyId,organizationType) {
		table = $("#table").DataTable({
			language: {
				"sInfoFiltered": "(共 _MAX_ 页)"
			},
			"pagingType": "simple_numbers",//设置分页控件的模式
		    searching: false,//屏蔽datatales的查询框
		    aLengthMenu:[10],//设置一页展示10条记录
		    "bLengthChange": false,//屏蔽tables的一页展示多少条记录的下拉列表,
		    "processing": true, //打开数据加载时的等待效果
		    "serverSide": true,//打开后台分页
		    "ajax": {
		       "url": ctx+"/sys/v1/user/list", 
		       "type": 'POST',
		       "dataSrc": "aaData",
		       "data": {
		    	   organizationId: companyId,
		    	   organizationType: organizationType
		       }
		    },
		    "columnDefs": [
				{
					width: '20%',
					targets: -1,
					data: 'userStatus',
					render: function(data) {
						if(data == 0) {
							return "<shiro:hasPermission name='sys:user:info'><a class='btn btn-info btn-xs btn-detail'><i class='fa fa-search-plus'></i>详情</a></shiro:hasPermission>"+
							"<shiro:hasPermission name='sys:user:edit'><a class='btn btn-success btn-xs btn-edit'><i class='fa fa-edit'></i>编辑</a></shiro:hasPermission>"+
							"<shiro:hasPermission name='sys:user:on-off'><a class='btn btn-primary btn-xs btn-forbid'><i class='fa fa-plus'></i>启用</a></shiro:hasPermission>"+
							"<shiro:hasPermission name='sys:user:delete'><a class='btn btn-danger btn-xs btn-delete'><i class='fa fa-trash-o'></i>删除</a></shiro:hasPermission>"+
							"<shiro:hasPermission name='sys:user:updatePwd'><a class='btn btn-warning btn-xs btn-editpas'><i class='fa fa-edit'></i>修改密码</a></shiro:hasPermission>"
						}
						if(data == 1) {
							return "<shiro:hasPermission name='sys:user:info'><a class='btn btn-info btn-xs btn-detail'><i class='fa fa-search-plus'></i>详情</a></shiro:hasPermission>"+
							"<shiro:hasPermission name='sys:user:edit'><a class='btn btn-success btn-xs btn-edit'><i class='fa fa-edit'></i>编辑</a></shiro:hasPermission>"+
							"<shiro:hasPermission name='sys:user:on-off'><a class='btn btn-primary btn-xs btn-forbid'><i class='fa fa-plus'></i>禁用</a></shiro:hasPermission>"+
							"<shiro:hasPermission name='sys:user:delete'><a class='btn btn-danger btn-xs btn-delete'><i class='fa fa-trash-o'></i>删除</a></shiro:hasPermission>"+
							"<shiro:hasPermission name='sys:user:updatePwd'><a class='btn btn-warning btn-xs btn-editpas'><i class='fa fa-edit'></i>修改密码</a></shiro:hasPermission>"
						}
					}
				},
				{targets: 0,data: 'loginName'},
				{targets: 1,data: 'trueName'},
				{targets: 2,data: 'phone'},
				{targets: 3,data: 'organizationName'},
				{targets: 4,data: 'cityName'},
				{targets: 5,data: 'createTime'},
				{targets: 6,data: 'userStatus',render: function(data) {
					if(data == 0) {
						return "已禁用";
					}
					else if(data == 1) {
						return "已启用";
					}
					else {
						return "无";
					}
				}}
			]
		});
		return table;
	}
</script>